package com.smart.service.impl;

import java.util.List;
import java.util.Arrays;
import com.smart.entity.SysDictDetail;
import com.smart.mapper.SysDictDetailMapper;
import com.smart.service.SysDictDetailService;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;

/**
 * @author lgb
 * @date 2020年6月10日 下午4:47:55
 * Copyright (C) 深圳工勘科技
 * @说明: 字典详情serviceImpl
 **/
@Service
public class SysDictDetailServiceImpl extends ServiceImpl<SysDictDetailMapper,
		SysDictDetail> implements SysDictDetailService{

    @Override
    public List<SysDictDetail> selectDictDataByType(String dictType) {
        return list(new LambdaQueryWrapper<SysDictDetail>()
                .eq(SysDictDetail::getDictType, dictType)
                .eq(SysDictDetail::getStatus,"1"));
    }

    @Override
    public IPage<SysDictDetail> getPage(SysDictDetail dictDetail,Integer pageSize,Integer pageNum) {
        return page(new Page<>(pageNum, pageSize), new LambdaQueryWrapper<>(dictDetail));
    }

    @Override
    public SysDictDetail selectById(Long id) {
        return this.baseMapper.selectById(id);
    }

    @Override
    public int create(SysDictDetail dictDetail) {
        return this.baseMapper.insert(dictDetail);
    }

    @Override
    public int updateStatus(Long id, String status) {
        SysDictDetail sysDictDetail = new SysDictDetail();
        sysDictDetail.setId(id.intValue());
        sysDictDetail.setStatus(status);
        return this.baseMapper.updateById(sysDictDetail);
    }

    @Override
    public int update(Long id, SysDictDetail dictDetail) {
        dictDetail.setId(id.intValue());
        return this.baseMapper.updateById(dictDetail);
    }

    @Override
    public int deleteByIds(Long[] ids) {
        return this.baseMapper.deleteBatchIds(Arrays.asList(ids));
    }
    
}